package com.otogami.server.rest;

import java.util.Collection;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.otogami.core.model.Videogame;
import com.otogami.server.service.VideogameService;

@Path("/videogame")
public class VideogameRestController {

	private final static Logger LOG = LoggerFactory.getLogger(VideogameRestController.class);

	@GET
	@Path("/healthcheck")
	public Response healthcheck() {

		LOG.info("Healthcheck successful");
		return Response.status(200).build();
	}

	@PUT
	@Path("/update")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response update(Collection<Videogame> videogameList) {

		LOG.info("Updating {} videogames...", videogameList.size());

		VideogameService service = new VideogameService();
		service.update(videogameList);

		return Response.ok().build();
	}

}
